package ru.study.thinkin.chapter11;

import java.util.*;


public class ListFeature {

	public static void main(String[] args) {
		Random rand = new Random(50);
		List<Pet> pets = Pets.arrayList(7);
		System.out.println(pets);
		Hamster h = new Hamster();
		pets.add(h);
		System.out.println(pets);
		System.out.println(pets.contains(h));
		pets.remove(h);
		
		Pet p = pets.get(2);
		System.out.println(pets.indexOf(p));
		
		List<Pet> subs = pets.subList(5,7);
		System.out.println(subs);
		
		List copy = new ArrayList(pets);		
		
		System.out.println(copy);
		System.out.println(copy.retainAll(subs));
		System.out.println(copy);
		
		copy = new ArrayList(pets);
		copy.removeAll(subs);
		System.out.println(copy);
		
		//pets.remove(0);
		System.out.println(pets);
		pets.addAll(3,new ArrayList(Arrays.asList(new Rat(),new Rat())));
		System.out.println(pets);
		Pet[] pa = pets.toArray(new Pet[0]);
		System.out.println(pa[2].id);
	}

}
